#include "gfx/legato/generated/screen/le_gen_screen_Screen2.h"

// screen member widget declarations
leWidget* root0;

leWidget* Screen2_PanelWidget0;
leLabelWidget* Screen2_TouchAnyWhereLabel;

static leBool initialized = LE_FALSE;
static leBool showing = LE_FALSE;

leResult screenInit_Screen2(void)
{
    if(initialized == LE_TRUE)
        return LE_FAILURE;

    initialized = LE_TRUE;

    return LE_SUCCESS;
}

leResult screenShow_Screen2(void)
{
    if(showing == LE_TRUE)
        return LE_FAILURE;

    // layer 0
    root0 = leWidget_New();
    root0->fn->setSize(root0, 800, 480);
    root0->fn->setBackgroundType(root0, LE_WIDGET_BACKGROUND_NONE);
    root0->fn->setMargins(root0, 0, 0, 0, 0);
    root0->flags |= LE_WIDGET_IGNOREEVENTS;
    root0->flags |= LE_WIDGET_IGNOREPICK;

    Screen2_PanelWidget0 = leWidget_New();
    Screen2_PanelWidget0->fn->setPosition(Screen2_PanelWidget0, 0, 0);
    Screen2_PanelWidget0->fn->setSize(Screen2_PanelWidget0, 800, 480);
    Screen2_PanelWidget0->fn->setScheme(Screen2_PanelWidget0, &BaseBlack_ForegroundWhite);
    root0->fn->addChild(root0, (leWidget*)Screen2_PanelWidget0);

    Screen2_TouchAnyWhereLabel = leLabelWidget_New();
    Screen2_TouchAnyWhereLabel->fn->setPosition(Screen2_TouchAnyWhereLabel, 80, 440);
    Screen2_TouchAnyWhereLabel->fn->setSize(Screen2_TouchAnyWhereLabel, 660, 30);
    Screen2_TouchAnyWhereLabel->fn->setScheme(Screen2_TouchAnyWhereLabel, &BaseWhite_TextBlack);
    Screen2_TouchAnyWhereLabel->fn->setHAlignment(Screen2_TouchAnyWhereLabel, LE_HALIGN_CENTER);
    Screen2_TouchAnyWhereLabel->fn->setVAlignment(Screen2_TouchAnyWhereLabel, LE_VALIGN_TOP);
    Screen2_TouchAnyWhereLabel->fn->setString(Screen2_TouchAnyWhereLabel, (leString*)&string_TouchAnywhere);
    root0->fn->addChild(root0, (leWidget*)Screen2_TouchAnyWhereLabel);

    leAddRootWidget(root0, 0);
    leSetLayerColorMode(0, LE_COLOR_MODE_RGB_565);

    showing = LE_TRUE;

    return LE_SUCCESS;
}

void screenUpdate_Screen2(void)
{
}

void screenHide_Screen2(void)
{

    leRemoveRootWidget(root0, 0);
    leWidget_Delete(root0);
    root0 = NULL;

    Screen2_PanelWidget0 = NULL;
    Screen2_TouchAnyWhereLabel = NULL;


    showing = LE_FALSE;
}

void screenDestroy_Screen2(void)
{
    if(initialized == LE_FALSE)
        return;

    initialized = LE_FALSE;
}

leWidget* screenGetRoot_Screen2(uint32_t lyrIdx)
{
    if(lyrIdx >= LE_LAYER_COUNT)
        return NULL;

    switch(lyrIdx)
    {
        case 0:
        {
            return root0;
        }
        default:
        {
            return NULL;
        }
    }
}

